package com.jk.controller;

import com.jk.bean.GuangGao;
import com.jk.bean.Staff;
import com.jk.bean.User;
import com.jk.service.UserService;
import com.jk.utils.ReceivePage;
import com.jk.utils.SendPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("user")
public class UserController {

    @Autowired
    private UserService userService;


    //查询
    @ResponseBody
    @RequestMapping("queryUser")
    public SendPage queryUser(User user, ReceivePage rp){

        return userService.queryUser(user,rp);
    }


    //删除用户
    @ResponseBody
    @RequestMapping("delUser")
    public String delUser(String ids){

        userService.delUser(ids);
        return "1";
    }


    //回显
    @ResponseBody
    @RequestMapping("queryUserById")
    public User queryUserById(String id){


        return userService.queryUserById(id);
    }

    //修改
    @ResponseBody
    @RequestMapping("updateUser")
    public String updateUser(User user, HttpServletRequest request , MultipartFile fileName){

        userService.updateUser(user,request,fileName);
        return "";
    }

    //查询员工
    @ResponseBody
    @RequestMapping("queryStaff")
    public SendPage queryStaff(ReceivePage receivePage){

        return userService.queryStaff(receivePage);
    }

    //删除员工
    @ResponseBody
    @RequestMapping("delStaff")
    public String delStaff(String ids){

        userService.delStaff(ids);
        return "1";
    }

    //添加员工
    @ResponseBody
    @RequestMapping("addStaff")
    public String addStaff(Staff staff){
        userService.addStaff(staff);
        return "1";
    }

    //回显员工
    @ResponseBody
    @RequestMapping("queryStaffById")
    public Staff queryStaffById(String id){

        return userService.queryStaffById(id);
    }

    //加入黑名单
    @ResponseBody
    @RequestMapping("updateUserState")
    public String updateUserState(User user){

        userService.updateUserState(user);
        return "1";
    }

    @ResponseBody
    @RequestMapping("queryYuLeSP")
    public SendPage queryYuLeSP(ReceivePage  page){
        return  userService.queryYuLeSP(page);
    }

    @ResponseBody
    @RequestMapping("tongGuo")
    public  String  tongGuo(String  ids){
        userService.tongGuo(ids);
        return  "";
    }

    @ResponseBody
    @RequestMapping("JuJueTuiJian")
    public String  JuJueTuiJian(String  ids){
        userService.JuJueTuiJian(ids);
        return  "";
    }

    @ResponseBody
    @RequestMapping("queryGuangGaoInfo")
    public SendPage queryGuangGaoInfo(ReceivePage  page){
        return  userService.queryGuangGaoInfo(page);
    }

    @ResponseBody
    @RequestMapping("updateGGW")
    public  String  updateGGW(GuangGao  gg){
        userService.updateGGW(gg);
        return  "";
    }


    @ResponseBody
    @RequestMapping("updateStatus")
    public String updateStatus(User user){

        userService.updateStatus(user);
        return "1";
    }

    @ResponseBody
    @RequestMapping("queryDKS")

    public  SendPage  queryDKS(ReceivePage  page){
        return  userService.queryDKS(page);
    }

    @ResponseBody
    @RequestMapping("deleteDKS")
    public  String  deleteDKS(String  ids){
        return  userService.deleteDKS(ids);
    }
}

